const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,
  
  // 开发服务器配置
  devServer: {
    host: '0.0.0.0',
    port: 8088,
    open: false,
    allowedHosts: 'all',
    client: {
      webSocketURL: 'wss://hm.yunxitech.cn/ws',
    },
    
    // 代理配置 - 解决CORS问题
    proxy: {
      '/api': {
        target: 'https://hm.yunxitech.cn',
        changeOrigin: true,
        secure: true,
        // 保持完整的API路径
        pathRewrite: {
          '^/api': '/api'  // 保持/api前缀
        },
        logLevel: 'debug',
        ws: true,
        timeout: 10000,
        headers: {
          'Access-Control-Allow-Origin': '*',
          'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,OPTIONS,PATCH',
          'Access-Control-Allow-Headers': 'Content-Type,Authorization,X-Requested-With,Accept,Origin'
        }
      }
    }
  },

  // 构建配置
  configureWebpack: {
    resolve: {
      fallback: {
        "path": require.resolve("path-browserify")
      }
    }
  }
}) 